package cn.bdqn.service;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.bdqn.dao.CommentMapper;
import cn.bdqn.dao.ComplaintsMapper;
import cn.bdqn.dao.OpinionMapper;
import cn.bdqn.dao.RepairMapper;
import cn.bdqn.dao.UsersMapper;
import cn.bdqn.entity.Users;
import cn.bdqn.util.Page;

@Service("usersService")
public class UsersServiceImpl implements UsersService {
	@Autowired
	private UsersMapper usersMapper;
	@Autowired
	private CommentMapper commentMapper;
	@Autowired
	private ComplaintsMapper complaintsMapper;
	@Autowired
	private RepairMapper repairMapper;
	@Autowired
	private OpinionMapper opinionMapper;
	@Override
	public Integer queryUsersCount() {
		return usersMapper.queryUsersCount();
	}
	@Override
	public Users queryLogin(Users users) {
		return usersMapper.queryLogin(users);
	}
	@Override
	public Users queryUserName(String username) {
		return usersMapper.queryUserName(username);
	}
	@Override
	public Users queryUserEmail(String email) {
		return usersMapper.queryUserEmail(email);
	}
	@Override
	public Users queryUserByuserid(Integer userid) {
		return usersMapper.queryUserByuserid(userid);
	}
	@Override
	public Integer updateUsers(Users users) {
		return usersMapper.updateUsers(users);
	}
	@Override
	public void queryUsers(String username,Integer floorid,
			Integer layerid,
			Integer roomid, Page<Users> page) {
		Integer count=usersMapper.queryCountUsers(floorid, layerid, roomid, username);
		page.setTotalCount(count);
		List<Users> list=usersMapper.queryAllUsers(username, page.getStart(), page.getPageSize(), floorid, layerid, roomid);
		page.setList(list);		
	}
	@Override
	public Integer saveusers(Users users) {
		return usersMapper.saveusers(users);
	}
	@Override
	public Integer querypersonnum(Integer floorid, Integer layerid, Integer roomid) {
		return usersMapper.querypersonnum(floorid, layerid, roomid);
	}
	@Override
	public void deleteUsers(Integer userid) {
		commentMapper.deleteCommentByUserid(userid);
		complaintsMapper.deleteComplaintsByuserid(userid);
		repairMapper.deleteRepairByUserid(userid);
		opinionMapper.deleteOpinionByUserid(userid);
		usersMapper.deleteUsers(userid);
		
	}

}
